function showAddCase() {
    document.querySelector('.main-bg').style.display = 'block';
    document.querySelector('.input-wrapper').style.display = 'block';
}

function closeAddCase() {
    document.querySelector('.main-bg').style.display = 'none';
    document.querySelector('.input-wrapper').style.display = 'none';
}

//封装删除用例的方法
function deleteCase(event) {
    event.target.parentNode.parentNode.remove();
}


function addCase() {
    //创建一个空对象用于存储信息
    let caseInfo = {};
    //获取caseForm表单的元素并形成formdata对象
    let caseForm = document.getElementById("caseForm")
    let formdata = new FormData(caseForm)
    //遍历formdata存到caseInfo
    formdata.forEach((value, key) => {
        caseInfo[key] = value
    })
    //创建tr，拼接td
    let newline = document.createElement("tr");
    for (let key in caseInfo) {
        if (key !== 'caseType') {
            let td = document.createElement("td");
            td.append(caseInfo[key]);
            newline.append(td);
        }
    }
    //newline放到表格里
    document.getElementById("caseTable").append(newline);
    saveToStorage(caseInfo);
    closeAddCase();
}

function saveToStorage(caseInfo){
    window.sessionStorage.setItem("新用例",JSON.stringify(caseInfo));
}

function storageToRow(){
    let caseString=window.sessionStorage.getItem("新用例");
    let newCase=JSON.parse(caseString);
    let newline = document.createElement("tr");
    for (let key in newCase) {
        if (key !== 'caseType') {
            let td = document.createElement("td");
            td.append(newCase[key]);
            newline.append(td);
        }
    }
    //newline放到表格里
    document.getElementById("caseTable").append(newline);

}